package com.xintonghua.bussiness.adapter;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.xintonghua.base.adapter.BaseAdapter;
import com.xintonghua.base.utils.MyUtils;
import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.bean.MemberBirthdayBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/1/11.
 * 包名：com.xintonghua.bussiness.adapter
 */

public class BrithAdapter extends BaseAdapter<MemberBirthdayBean, BrithAdapter.BrithViewHolder> {

    List<MemberBirthdayBean> list = new ArrayList<>();

    Context context;

    public BrithAdapter(Activity mActivity, List<MemberBirthdayBean> list) {
        super(mActivity, list);
        context = (Context) mActivity;
        this.list = list;
    }

    @Override
    public BrithViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.adapter_brith, parent, false);
        return new BrithViewHolder(view);
    }

    @Override
    public void onBindViewHolder(BrithViewHolder holder, final int position) {

        holder.tvCustomerName.setText("" + list.get(position).getNickname());
        holder.tvLinkname.setText("" + list.get(position).getUsername());
        holder.ivCall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                MyUtils.callDial(context, "" + list.get(position).getPhone());
            }
        });
        holder.tvUpToDian.setText("" + list.get(position).getBirth());
    }


    class BrithViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_customer_name)
        TextView tvCustomerName;
        @BindView(R.id.tv_up_to_dian)
        TextView tvUpToDian;
        @BindView(R.id.iv_call)
        ImageView ivCall;
        @BindView(R.id.tv_linkname)
        TextView tvLinkname;

        public BrithViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

    int birthdayType = 0;

    public int getBirthdayType() {
        return birthdayType;
    }

    public void setBirthdayType(int birthdayType) {
        this.birthdayType = birthdayType;
    }
}
